﻿namespace IMES.Utils
{
    public class ConfigHelper
    {
        private static ConfigHelper manager=new ConfigHelper ();
        private IniParser initConfig = null;
        public ConfigHelper()
        {
            initConfig = new IniParser("config.ini");
        }
        /// <summary>
        /// 配置处理单例
        /// </summary>
        public static ConfigHelper Instance
        {
            get { return manager; }
        }

        /// <summary>
        /// 获取INI 配置信息
        /// </summary>
        /// <param name="sectionName">分组名称</param>
        /// <param name="settingName">配置项名称</param>
        /// <returns></returns>

        public String GetInitConfig(String sectionName, String settingName)
        {
            return initConfig.GetSetting(sectionName, settingName);
        }

        /// <summary>
        /// 保存 INI 配置信息
        /// </summary>
        /// <param name="sectionName">分组名称</param>
        /// <param name="settingName">设置名称</param>
        /// <param name="value">返回值</param>
        public void SaveInitConfig(string sectionName, String settingName,string value,bool isUpFile=false)
        {
            initConfig.AddSetting(sectionName, settingName, value);
            if(isUpFile )
            {
                initConfig.SaveSettings();
            }
        }
    }
}
